<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page import="com.beaut.project.util.FlowUtility" %>
<%@ include file="/public/header.jsp"%>

<html>
	<head>
	</head>
	<script type="text/javascript">
		var xmStatus = new Array("新建","未开工", "在建", "完工", "验收", "送审", "开票" ,"结算", "关闭"); 
		$(function(){
			$("#searchValue").keypress(function(e) { 
		    	// 回车键事件 
		     	if(e.which == 13) { 
		     		 doSearch();
		       	} 
			});
			$("#dept_id").combotree({
				url:'<%=contextPath %>/springMVC/group/listDepartment',
				method:'POST',
				animate:true,
				lines:true,
				onChange:function(){
					doSearch();
				}
			});
			$("#table").datagrid({
				title:"项目收支情况",
				iconCls:'icon-edit',
				loadMsg:'正在加载数据，请稍后......',
				url:'<%=contextPath %>/springMVC/xm/listPageFinanceInfo',
				rownumbers:true,
				fitColumns:false,
				singleSelect:true,
				idField:'id',
				frozenColumns:[[
				    {title:'主键',field:'id',hidden:true},
					{title:'项目进度',field:'xm_progress_status_desc',width:80,align:'center',formatter:function(value,rowData,rowIndex){
					    return xmStatus[rowData.xm_progress_status_desc];
					}},
					{title:'所属部门',field:'admin_dept',width:80,align:'center'},
					{title:'建设单位编号',field:'construct_code',width:80,align:'center'},
					{title:'项目编号',field:'xm_code',width:80,align:'center'},
					{title:'项目名称',field:'xm_name',width:250,align:'center'},
					{title:'项目关闭时间',field:'end_time',width:80,align:'center'}
				]],
				columns:[
					[
						{title:'收入',width:400,align:'center',colspan:6},
						{title:'支出',width:1400,align:'center',colspan:13},
						{title:'已分摊毛利',field:'already_profit',width:100,align:'center',rowspan:4},
						{title:'剩余毛利',field:'earn_money',width:100,align:'center',rowspan:4,formatter:function(value,rowData,rowIndex){
							
							return parseFloat((rowData.has_receivable+rowData.already_money)-(rowData.loan_reimburs+rowData.xm_manage_price+rowData.company_tax+rowData.direct_reimburse+rowData.purchase_has_payable+rowData.pay_value+rowData.advancesMoney+rowData.work_end_pay)-(rowData.already_profit)).toFixed(2)  ;
						}}
					],
					[
						{title:'已开票',field:'out_invoice',width:100,align:'center',rowspan:3},
						{title:'应收',field:'account_receivable',width:100,align:'center',rowspan:3},
						{title:'实收',field:'has_receivable',width:100,align:'center',rowspan:3},
						{title:'质保金',width:100,align:'center',colspan:2},
						{title:'还/扣垫款',field:'already_money',width:100,align:'center',rowspan:3},
						{title:'管理费',field:'xm_manage_price',width:100,align:'center',rowspan:3},
						{title:'税金',field:'company_tax',width:100,align:'center',rowspan:3},
						{title:'个人结算费',width:200,align:'center',colspan:2},
						{title:'分包费',width:600,align:'center',colspan:6},
						{title:'采购费',width:300,align:'center',colspan:3}
						
					],
					[
						{title:'应收',field:'warranty_value',width:100,align:'center',rowspan:2},
						{title:'已收',field:'already_receive',width:100,align:'center',rowspan:2},
						//{title:'借款总额',field:'loanMoney',width:100,align:'center',rowspan:2},
						{title:'直接报账额',field:'direct_reimburse',width:100,align:'center',rowspan:2},
						{title:'借款报账额',field:'loan_reimburs',width:100,align:'center',rowspan:2},
						{title:'已收票',field:'work_in_invoice',width:100,align:'center',rowspan:2},
						{title:'应付',field:'already_pay',width:100,align:'center',rowspan:2},
						{title:'实付',width:300,align:'center',colspan:3},
						{title:'扣款',field:'work_cut_pay',width:100,align:'center',rowspan:2},
						{title:'已收票',field:'purchase_in_invoice',width:100,align:'center',rowspan:2},
						{title:'应付',field:'purchase_account_payable',width:100,align:'center',rowspan:2},
						{title:'已付',field:'purchase_has_payable',width:100,align:'center',rowspan:2}
						
					],
					[
						{title:'进度支付',field:'pay_value',width:100,align:'center'},
						{title:'垫款',field:'advancesMoney',width:100,align:'center'},
						{title:'结算支付',field:'work_end_pay',width:100,align:'center'}
					]
				],
				pageSize:10,
				pageList : [10,50,100],  
				pagination:true,
				toolbar:"#tb",
				onLoadSuccess:function(rtJson){
					if(rtJson.rtState== '1')
					{
						$.messager.alert('提示',rtJson.rtMsrg);
					}
				}
			});
		});
		function doSearch()
		{
			var start_time=$('#start_time').datebox('getValue');  
			var end_time=$('#end_time').datebox('getValue');  
			var searchValue = $('#searchValue').val();
			var dept_id = $("#dept_id").combotree('getValue');
			$('#table').datagrid('load',{
				searchValue:searchValue,
				start_time:start_time,
				dept_id :dept_id,
				end_time:end_time
				
			});
		}
		function exportExcel()
		{
			var start_time=$('#start_time').datebox('getValue');  
			var end_time=$('#end_time').datebox('getValue');  
			var searchValue = $('#searchValue').val();
			var dept_id = $("#dept_id").combotree('getValue');
			
			window.open('<%=contextPath%>/springMVC/excel/xmFinanceInfoExcel?start_time='+start_time+'&end_time='+end_time+'&searchValue='+searchValue+'&dept_id='+dept_id);
		}
	</script>
	<body style="height: 97%">
		<div id="table" data-options="fit:true"></div>
		<div id="tb" style="padding:3px;height:auto">
			<div align="right">
				所属部门：<input  id="dept_id" name="dept_id" class="easyui-combotree">&nbsp;&nbsp; 
				开始时间：<input id="start_time" name="start_time" class="easyui-datebox" />&nbsp;&nbsp;&nbsp;结束时间：<input id="end_time" name="end_time" class="easyui-datebox" />
				项目编号/名称：<input id="searchValue" name="searchValue" style="width:150px" title="建设单位编号/项目编号/名称" placeholder="建设单位编号/项目编号/名称 "  />&nbsp;&nbsp; 
				<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-search',plain:true" onclick="doSearch();"></a>
				<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-excel',plain:true" onclick="exportExcel();"></a>
			</div>
	</body>
</html>